<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <view class="jtop_c">个人信息</view>
      <view class="jtop_r" @tap="logoTime"
        ><image src="../../static/img/index/ic_ellipsis.png"></image
      ></view>
    </view>
    <view class="tophr"></view>

    <view class="tm_t">
      <image
        :src="avatar ? avatar : '../../static/img/Default_avatar.png'"
        class="tm_tl"
      ></image>
      <view class="tm_tr_t">
        <text>{{ name }}</text>
        <image
          src="../../static/img/index/new/ic_man.png"
          v-if="gender == 1"
        ></image>
        <image
          src="../../static/img/index/new/ic_woman.png"
          v-if="gender == 0"
        ></image>
      </view>
      <view class="tm_tr_f">{{ duty }} </view>
    </view>

    <view class="tm_f">
      <view class="tm_fb" @click="pc(phone)">
        <view class="tm_f1">
          电话
        </view>
        <view class="tm_f2">
          {{ phone }}
        </view>
        <image src="../../static/img/index/new/ic_phone_blue.png"></image>
      </view>
      <view class="tm_fb">
        <view class="tm_f1">
          邮箱
        </view>
        <view class="tm_f2">
          {{ email }}
        </view>
        <image src="../../static/img/index/new/ic_mail_blue.png"></image>
      </view>
    </view>

    <view class="tm_f">
      <view class="tm_fb">
        <view class="tm_f1">
          公司
        </view>
        <view class="tm_f2">
          {{ identity }}
        </view>
      </view>
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop2 ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="btTCC"></view>

      <view class="tc_fbox">
        <view class="tc_fbox_bt3" @click="btTC_bj">
          编辑
        </view>
        <view class="tc_fbox_bt2" @click="btTC_jdel">
          删除
        </view>
        <view class="tc_fbox_bt" @click="btTCC">
          取消
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),

  data() {
    return {
      repeat_click: true,
      ashowpop2: false,

      ashowpop: false,
      ashowpop_jrename: false,
      ashowpop_jdel: false,
      ashowpopT: false,
      bj: false,
      yd: false,
      purchaseTime: '',
      remark: '',
      amount: '',
      model: '',
      brand: '',
      name: '',

      index: 0,
      array: [],
      array2: [],
      dw: '',

      show_xl: false,
      js: '',
      ky: true,
      id: '',
      jsid: '',
      items: [],
      dyid: '',
      mrtx: '../../static/img/Default_avatar.png',
      avatar: '',
      mrtx2: '',
      dw: '女',
      index: '0',
      jsex: ['女', '男', '其他'],
      jsex2: [
        { value: '0', label: '女' },
        { value: '1', label: '男' },
        { value: '2', label: '其他' },
      ],
      ashowpop: false,
      name: '',
      phone: '',
      email: '',
      identity: '',
      duty: '',
    };
  },
  onLoad() {
    this.jc = uni.getStorageSync('jc');
    console.log('ccccc:', this.jc);

    this.name = this.jc.name;
    this.phone = this.jc.phone;
    this.gender = this.jc.gender;
    this.id = this.jc.id;
    this.projectId = this.jc.projectId;

    if (this.jc.email) {
      this.email = this.jc.email;
    }
    if (this.jc.identity) {
      this.identity = this.jc.identity;
    }
    if (this.jc.duty) {
      this.duty = this.jc.duty;
    }
    if (this.jc.avatar) {
      this.avatar = this.jc.avatar;
    }
  },
  onShow() {
    console.log(111111);
    this.ashowpop2 = false;
  },

  methods: {
    btTC_bj() {
      //  var jc = this.items.filter((item) => {
      //      return item.id == this.jqeditid;
      //  });

      //  console.log(jc)

      // uni.setStorageSync("jc",jc[0]);

      uni.navigateTo({
        url: '../main/tel_edit',
      });
    },

    logoTime(e) {
      console.log(e);
      this.jqeditid = this.id;
      this.ashowpop2 = true;
    },

    btTC_jdel() {
      var aa = this.jqeditid;
      request({
        url: `/biz/addr-book/${aa}`,
        method: 'DELETE',

        success: res => {
          if (res.data.success == true) {
            this.ashowpop2 = false;
            wx.showToast({
              title: '删除成功',
              icon: 'none',
              duration: 1500,
              success: function() {
                setTimeout(function() {
                  // uni.navigateBack()
                  uni.navigateTo({
                    url: '../main/tel',
                  });
                }, 1500);
              },
            });
          } else {
            // 错误
            this.ashowpop2 = false;
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    btTCC(e) {
      this.ashowpop2 = !this.ashowpop2;
    },

    pc(e) {
      console.log(e);

      uni.makePhoneCall({
        phoneNumber: e,
      });
    },
    navigateBack() {
      uni.navigateBack();
    },
    tel_more() {
      uni.navigateTo({
        url: '../main/tel_more',
      });
    },
    add() {
      uni.navigateTo({
        url: '../main/tel_add',
      });
    },
  },
};
</script>

<style>
.tm_t {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 20rpx 0 0;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
}
.tm_tl {
  width: 120rpx;
  height: 120rpx;
  display: block;
  float: left;
  margin: 30rpx 20rpx 30rpx 30rpx;
}
.tm_tr_t {
  width: 500rpx;
  height: auto;
  display: block;
  float: left;
  margin: 30rpx 0rpx 0rpx 0rpx;
}
.tm_tr_t text {
  width: auto;
  height: auto;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
  line-height: 42rpx;
  margin: 0 0 0 0rpx;
}
.tm_tr_t image {
  width: 32rpx;
  height: 32rpx;
  display: block;
  float: left;
  margin: 8rpx 0 0 10rpx;
}
.tm_tr_f {
  width: 500rpx;
  height: auto;
  display: block;
  float: left;
  margin: 10rpx 0rpx 0rpx 0rpx;
  font-size: 24rpx;
  color: #999999;
  line-height: 32rpx;
}

.tm_f {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 20rpx 0 0;
}
.tm_fb {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.tm_fb:last-child {
  border: 0;
}
.tm_f1 {
  width: auto;
  margin: 0 50rpx 0 0rpx;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
}
.tm_f2 {
  width: auto;
  margin: 0 50rpx 0 0rpx;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
}
.tm_f image {
  width: 48rpx;
  margin: 21rpx 30rpx 0 0rpx;
  height: 48rpx;
  display: block;
  float: right;
}

.tophr {
  width: 100%;
  height: 88rpx;
}
.uni-searchbar {
  box-shadow: none;
}

.dcf {
  width: 100%;
  height: 120rpx;
  display: block;
  float: left;
  position: fixed;
  left: 0;
  bottom: 0;
  background: #ffffff;
  box-shadow: inset 0px 1px 0px #dddddd;
  z-index: 1000;
  padding: 18rpx 30rpx;
  box-sizing: border-box;
}
.dcf_tx {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 0rpx 20rpx 0rpx 0;
}
.dcf_t {
  width: auto;
  height: 84rpx;
  line-height: 84rpx;
  display: block;
  float: right;
  margin: 0rpx 0rpx 0rpx 0;
  font-size: 36rpx;
  color: #256aff;
}

.index {
  background: rgb(242, 242, 242);
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_r {
  width: auto;
  height: 88rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
  line-height: 88rpx;
  font-size: 32rpx;
  color: #000000;
  color: #256aff;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}

.uni-searchbar {
  background: rgb(242, 242, 242);
}
.index .uni-searchbar__box {
  background: #ffffff !important;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox_bt3 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-bottom: 1px solid #dddddd;
  background: #ffffff;
}
</style>
